﻿/*
 *  XTL - XNA Tool Library, a collection with usefull XNA classes
 * 
 *  Copyright (C) 2009 Sebastian Schäfer
 * 
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License 
 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace XTL.Input
{
    /// <summary>
    /// The main class of state management, the only state class that should be used inside a program
    /// </summary>
    public class XNAState
    {
        /// <summary>
        /// Access to the managed XNAStateKeyboard
        /// </summary>
        public XNAStateKeyboard Keys { get; private set; }
        /// <summary>
        /// Access to the managed XNAStateMouse
        /// </summary>
        public XNAStateMouse Mouse { get; private set; }

        /// <summary>
        /// Constructs a new XNAState object that manages mouse and keyboard states
        /// </summary>
        /// <param name="stateKeys">Keyboard.GetState()</param>
        /// <param name="stateMouse">Mouse.GetState()</param>
        public XNAState(KeyboardState stateKeys, MouseState stateMouse)
        {
            Keys = new XNAStateKeyboard(stateKeys);
            Mouse = new XNAStateMouse(stateMouse);
        }

        /// <summary>
        /// Update routine, should be called before state checking
        /// </summary>
        /// <param name="stateKeys">Keyboard.GetState()</param>
        /// <param name="stateMouse">Mouse.GetState()</param>
        public void Update(KeyboardState stateKeys, MouseState stateMouse)
        {
            Keys.Update(stateKeys);
            Mouse.Update(stateMouse);
        }
    }
}
